import sys
import os

sys.path.append(os.getcwd())
import runtest

class compare_memory(runtest.Test):
    conditions = {}
    arguments = ""
    def __init__(self, _options, _conditions, arguments="", test_name=""):
        runtest.Test.__init__(self, _options, test_name)
        self.options['silent'] = True
        self.options['working_dir'] = runtest.options.workdir
        self.arguments = arguments
        self.conditions = _conditions
    def test(self):
        report = self.runsp(self.options, arguments=self.arguments)
        report1 = self.runasp(self.options, arguments=self.arguments)
        if 'terminate_reason' in self.conditions:
            self.check(report.terminate_reason, self.conditions['terminate_reason'])
        if 'exception' in self.conditions:
            self.check(report.exception, self.conditions['exception'])
        if 'exit_status' in self.conditions:
            self.check(report.exit_status, self.conditions['exit_status'])


runtest.use_tests(runtest.Tests( [                                runtest.result_test({"memory_limit":"10"}, {"terminate_reason":"MEMORY_LIMIT"}, arguments="102400 1024"),

                                 runtest.result_test({"memory_limit":"10"}, {"terminate_reason":"MEMORY_LIMIT"}, arguments="10485760 10240"),
                                ]))

